<!--
 * @Descripttion: (/DC_CoverRivetingAssemble)
 * @Author: (admin)
 * @Date: (2024-11-04)
-->
<template>
    <div>
      <el-form :model="queryParams" label-position="right" inline ref="queryRef" v-show="showSearch" @submit.prevent>
        
        <el-form-item :label="$t('op20.col1')" prop="coverCode">
            <el-input v-model="queryParams.coverCode" placeholder="" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
         
          <el-form-item :label="$t('op20.col31')">
            <el-date-picker
              v-model="dateRange"
              style="width: 240px"
              type="daterange"
              range-separator="-"
              start-placeholder=""
              end-placeholder=""></el-date-picker>
          </el-form-item>
        
        <el-form-item>
          <el-button icon="search" type="primary" @click="handleQuery">{{ $t('btn.search') }}</el-button>
          <el-button icon="refresh" @click="resetQuery">{{ $t('btn.reset') }}</el-button>
        </el-form-item>
      </el-form>
      <!-- 工具区域 -->
      <el-row :gutter="15" class="mb10">
        <el-col :span="1.5">
          <!-- <el-button type="primary" v-hasPermi="['dccoverrivetingassemble:add']" plain icon="plus" @click="handleAdd">
            {{ $t('btn.add') }}
          </el-button> -->
        </el-col>
        <right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
      </el-row>
  
      <el-table
        :data="dataList"
        v-loading="loading"
        ref="table"
        border
        header-cell-class-name="el-table-header-cell"
        highlight-current-row
        @sort-change="sortChange"
        
        >
        <!-- <el-table-column prop="id" label="Id" align="center" v-if="columns.showColumn('id')"/>
        <el-table-column prop="dCId" label="DCId" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('dCId')"/> -->
        <el-table-column prop="coverCode" :label="$t('op20.col1')" width="150" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('coverCode')"/>
        <el-table-column prop="coverBlueCode" :label="$t('op20.col2')" width="150" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('coverBlueCode')"/>
        <el-table-column prop="pillarBlueCode" :label="$t('op20.col3')" width="150" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('pillarBlueCode')"/>
        <!-- <el-table-column prop="smallSolderRingBlueCode" label="焊环子篮码" width="150" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('smallSolderRingBlueCode')"/> -->
        <el-table-column prop="totalResult" label="总结果" align="center" :show-overflow-tooltip="true" />
        <el-table-column prop="ccD_2D1" :label="$t('op20.col4')" align="center" :show-overflow-tooltip="true" />
        <el-table-column prop="ccD_2D2" :label="$t('op20.col5')" align="center" :show-overflow-tooltip="true" />
        <el-table-column prop="ccD_3D" :label="$t('op20.col6')" align="center" :show-overflow-tooltip="true" />
        <el-table-column prop="coverResult" label="盖板检测结果"  align="center" :show-overflow-tooltip="true" />
        <el-table-column prop="wrExistence1" label="焊环有无左" align="center" :show-overflow-tooltip="true" />
        <el-table-column prop="wrExistence2" label="焊环有无右" align="center" :show-overflow-tooltip="true" />
        <el-table-column prop="lPostRivGapResult" label="定位柱缝隙左" align="center" :show-overflow-tooltip="true" />
        <el-table-column prop="rPostRivGapResult" label="定位柱缝隙右" align="center" :show-overflow-tooltip="true" />
        <el-table-column prop="pPinExistence1" label="定位柱有无左" align="center" :show-overflow-tooltip="true" />
        <el-table-column prop="pPinExistence2" label="定位柱有无右" align="center" :show-overflow-tooltip="true" />
        
        <el-table-column prop="pressTotalResult" label="压装总结果" align="center" :show-overflow-tooltip="true" />
        <el-table-column prop="pressResult1" label="压装结果1" align="center" :show-overflow-tooltip="true" />
        <el-table-column prop="pressResult2" label="压装结果2" align="center" :show-overflow-tooltip="true" />
        <el-table-column prop="pressValue1" label="压力值1" align="center" :show-overflow-tooltip="true" />
        <el-table-column prop="pressDisplacement1" label="压装位移1" width="100" align="center" :show-overflow-tooltip="true" />
        <el-table-column prop="pressValue2" label="压力值2" align="center" :show-overflow-tooltip="true" />
        <el-table-column prop="pressDisplacement2" label="压装位移2" width="100" align="center" :show-overflow-tooltip="true" />
      
        

        <el-table-column prop="holeDiameter" :label="$t('op20.col7')" width="110" align="center" v-if="columns.showColumn('holeDiameter')"/>
      <el-table-column prop="slotWidth" :label="$t('op20.col8')" width="110" align="center" v-if="columns.showColumn('slotWidth')"/>
      <el-table-column prop="slotLenUpper" :label="$t('op20.col9')" width="100" align="center" v-if="columns.showColumn('slotLenUpper')"/>
      <el-table-column prop="slotLenLower" :label="$t('op20.col10')" width="110" align="center" v-if="columns.showColumn('slotLenLower')"/>
      <el-table-column prop="slotWidthUpper" :label="$t('op20.col11')" width="110" align="center" v-if="columns.showColumn('slotWidthUpper')"/>
      <el-table-column prop="slotWidthLower" :label="$t('op20.col12')" width="110" align="center" v-if="columns.showColumn('slotWidthLower')"/>
      <el-table-column prop="flatness" :label="$t('op20.col13')" align="center" width="100" v-if="columns.showColumn('flatness')"/>
      <el-table-column prop="heightMax" :label="$t('op20.col14')" width="100" align="center" v-if="columns.showColumn('heightMax')"/>
      <el-table-column prop="heightMin" :label="$t('op20.col15')" width="100" align="center" v-if="columns.showColumn('heightMin')"/>
      <el-table-column prop="profile" :label="$t('op20.col16')" width="100" align="center" v-if="columns.showColumn('profile')"/>
      <el-table-column prop="positionDegree" :label="$t('op20.col17')" width="100" align="center" v-if="columns.showColumn('positionDegree')"/>
      
      <el-table-column prop="smallSolderRingBatchCode" :label="$t('op20.col18')" width="100" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('smallSolderRingBatchCode')"/>
      <el-table-column prop="postRivetingLocatingPinGapL1" :label="$t('op20.col19')" width="100" align="center" v-if="columns.showColumn('postRivetingLocatingPinGapL1')"/>
      <el-table-column prop="postRivetingLocatingPinGapL2" :label="$t('op20.col20')" width="100" align="center" v-if="columns.showColumn('postRivetingLocatingPinGapL2')"/>
      <el-table-column prop="postRivetingLocatingPinGapR1" :label="$t('op20.col21')" width="100" align="center" v-if="columns.showColumn('postRivetingLocatingPinGapR1')"/>
      <el-table-column prop="postRivetingLocatingPinGapR2" :label="$t('op20.col22')" width="100" align="center" v-if="columns.showColumn('postRivetingLocatingPinGapR2')"/>
      <el-table-column prop="postRivetingLocatingPinHeightL1" :label="$t('op20.col23')" width="100" align="center" v-if="columns.showColumn('postRivetingLocatingPinHeightL1')"/>
      <el-table-column prop="postRivetingLocatingPinHeightL2" :label="$t('op20.col24')" width="100" align="center" v-if="columns.showColumn('postRivetingLocatingPinHeightL2')"/>
      <el-table-column prop="postRivetingLocatingPinHeightR1" :label="$t('op20.col25')" width="100" align="center" v-if="columns.showColumn('postRivetingLocatingPinHeightR1')"/>
      <el-table-column prop="postRivetingLocatingPinHeightR2" :label="$t('op20.col26')" width="100" align="center" v-if="columns.showColumn('postRivetingLocatingPinHeightR2')"/>
      <el-table-column prop="postRivetingLocatingPinVerticalityL1" :label="$t('op20.col27')" width="100" align="center" v-if="columns.showColumn('postRivetingLocatingPinVerticalityL1')"/>
      <el-table-column prop="postRivetingLocatingPinVerticalityL2" :label="$t('op20.col28')" width="100" align="center" v-if="columns.showColumn('postRivetingLocatingPinVerticalityL2')"/>
      <el-table-column prop="postRivetingLocatingPinVerticalityR1" :label="$t('op20.col29')" width="100" align="center" v-if="columns.showColumn('postRivetingLocatingPinVerticalityR1')"/>
      <el-table-column prop="postRivetingLocatingPinVerticalityR2" :label="$t('op20.col30')" width="100" align="center" v-if="columns.showColumn('postRivetingLocatingPinVerticalityR2')"/>
      

        <el-table-column prop="assembleTime" :label="$t('op20.col31')" width="160" :show-overflow-tooltip="true"  v-if="columns.showColumn('assembleTime')"/>
        <!-- <el-table-column label="操作" width="160">
          <template #default="scope">
            <el-button type="success" size="small" icon="edit" title="编辑" v-hasPermi="['dccoverrivetingassemble:edit']" @click="handleUpdate(scope.row)"></el-button>
            <el-button type="danger" size="small" icon="delete" title="删除" v-hasPermi="['dccoverrivetingassemble:delete']" @click="handleDelete(scope.row)"></el-button>
          </template>
        </el-table-column> -->
      </el-table>
      <pagination :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
  
  
      <!-- 添加或修改对话框 -->
      <el-dialog :title="title" :lock-scroll="false" v-model="open" >
        <el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
          <el-row :gutter="20">
              
            <el-col :lg="12" v-if="opertype != 1">
              <el-form-item label="Id" prop="id">
                <el-input-number v-model.number="form.id" controls-position="right" placeholder="请输入Id" :disabled="true"/>
              </el-form-item>
            </el-col>
  
            <el-col :lg="12">
              <el-form-item label="DCId" prop="dCId">
                <el-input v-model="form.dCId" placeholder="请输入DCId" />
              </el-form-item>
            </el-col>
  
            <el-col :lg="12">
              <el-form-item label="盖板码" prop="coverCode">
                <el-input v-model="form.coverCode" placeholder="请输入盖板码" />
              </el-form-item>
            </el-col>
  
            <el-col :lg="12">
              <el-form-item label="盖板子篮码" prop="coverBlueCode">
                <el-input v-model="form.coverBlueCode" placeholder="请输入盖板子篮码" />
              </el-form-item>
            </el-col>
  
            <el-col :lg="12">
              <el-form-item label="柱子篮码" prop="pillarBlueCode">
                <el-input v-model="form.pillarBlueCode" placeholder="请输入柱子篮码" />
              </el-form-item>
            </el-col>
  
            <el-col :lg="12">
              <el-form-item label="焊环子篮码" prop="smallSolderRingBlueCode">
                <el-input v-model="form.smallSolderRingBlueCode" placeholder="请输入焊环子篮码" />
              </el-form-item>
            </el-col>
  
            <el-col :lg="12">
              <el-form-item label="组装时间" prop="assembleTime">
                <el-date-picker v-model="form.assembleTime" type="datetime" :teleported="false" placeholder="选择日期时间"></el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <template #footer v-if="opertype != 3">
          <el-button text @click="cancel">{{ $t('btn.cancel') }}</el-button>
          <el-button type="primary" @click="submitForm">{{ $t('btn.submit') }}</el-button>
        </template>
      </el-dialog>
    </div>
  </template>
  
  <script setup name="dccoverrivetingassemble">
  import { listDcCoverrivetingassemble,
   addDcCoverrivetingassemble, delDcCoverrivetingassemble, 
   updateDcCoverrivetingassemble,getDcCoverrivetingassemble, 
   } 
  from '@/api/business/dccoverrivetingassemble.js'
  const { proxy } = getCurrentInstance()
  const ids = ref([])
  const loading = ref(false)
  const showSearch = ref(true)
  const queryParams = reactive({
    pageNum: 1,
    pageSize: 10,
    sort: '',
    sortType: 'asc',
  })
  const dateRange = ref([])
  const columns = ref([
    // { visible: true, prop: 'id', label: 'Id' },
    // { visible: true, prop: 'dCId', label: 'DCId' },
    { visible: true, prop: 'coverCode', label: '盖板码' },
    { visible: true, prop: 'coverBlueCode', label: '盖板子篮码' },
    { visible: true, prop: 'pillarBlueCode', label: '柱子篮码' },
    { visible: true, prop: 'smallSolderRingBlueCode', label: '焊环子篮码' },
    { visible: true, prop: 'assembleTime', label: '组装时间' },
  ])
  const total = ref(0)
  const dataList = ref([])
  const queryRef = ref()
  const defaultTime = ref([new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)])
  
  
  var dictParams = [
  ]
  
  
  function getList(){
    loading.value = true
    const queryPara = proxy.addDateRange(queryParams, dateRange.value)
    console.log(queryPara);
    listDcCoverrivetingassemble(queryPara).then(res => {
      const { code, data } = res
      if (code == 200) {
        dataList.value = data.result
        total.value = data.totalNum
        loading.value = false
      }
    })
  }
  
  // 查询
  function handleQuery() {
    queryParams.pageNum = 1
    getList()
  }
  
  // 重置查询操作
  function resetQuery(){
    proxy.resetForm("queryRef")
    dateRange.value = []
    handleQuery()
  }
  // 自定义排序
  function sortChange(column) {
    var sort = undefined
    var sortType = undefined
  
    if (column.prop != null && column.order != null) {
      sort = column.prop
      sortType = column.order
  
    }
    queryParams.sort = sort
    queryParams.sortType = sortType
    handleQuery()
  }
  
  /*************** form操作 ***************/
  const formRef = ref()
  const title = ref('')
  // 操作类型 1、add 2、edit 3、view
  const opertype = ref(0)
  const open = ref(false)
  const state = reactive({
    single: true,
    multiple: true,
    form: {},
    rules: {
      dCId: [{ required: true, message: "DCId不能为空", trigger: "blur"     }],
    },
    options: {
    }
  })
  
  const { form, rules, options, single, multiple } = toRefs(state)
  
  // 关闭dialog
  function cancel(){
    open.value = false
    reset()
  }
  
  // 重置表单
  function reset() {
    form.value = {
      id: null,
      dCId: null,
      coverCode: null,
      coverBlueCode: null,
      pillarBlueCode: null,
      smallSolderRingBlueCode: null,
      assembleTime: null,
    };
    proxy.resetForm("formRef")
  }
  
  
  // 添加按钮操作
  function handleAdd() {
    reset();
    open.value = true
    title.value = '添加'
    opertype.value = 1
  }
  // 修改按钮操作
  function handleUpdate(row) {
    reset()
    const id = row.id || ids.value
    getDcCoverrivetingassemble(id).then((res) => {
      const { code, data } = res
      if (code == 200) {
        open.value = true
        title.value = '修改'
        opertype.value = 2
  
        form.value = {
          ...data,
        }
      }
    })
  }
  
  // 添加&修改 表单提交
  function submitForm() {
    proxy.$refs["formRef"].validate((valid) => {
      if (valid) {
  
        if (form.value.id != undefined && opertype.value === 2) {
          updateDcCoverrivetingassemble(form.value).then((res) => {
            proxy.$modal.msgSuccess("修改成功")
            open.value = false
            getList()
          })
        } else {
          addDcCoverrivetingassemble(form.value).then((res) => {
              proxy.$modal.msgSuccess("新增成功")
              open.value = false
              getList()
            })
        }
      }
    })
  }
  
  // 删除按钮操作
  function handleDelete(row) {
    const Ids = row.id || ids.value
  
    proxy
      .$confirm('是否确认删除参数编号为"' + Ids + '"的数据项？', "警告", {
        confirmButtonText: proxy.$t('common.ok'),
        cancelButtonText: proxy.$t('common.cancel'),
        type: "warning",
      })
      .then(function () {
        return delDcCoverrivetingassemble(Ids)
      })
      .then(() => {
        getList()
        proxy.$modal.msgSuccess("删除成功")
      })
  }
  
  
  
  
  
  handleQuery()
  </script>